<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Prototype Unit test file</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <script src="../../dist/prototype.js" type="text/javascript"></script>
  <script src="../lib/unittest.js" type="text/javascript"></script>
  <link rel="stylesheet" href="../test.css" type="text/css" />
  <style type="text/css" media="screen">
  /* <![CDATA[ */
    #testcss1 { font-size:11px; color: #f00; }
    #testcss2 { font-size:12px; color: #0f0; display: none; }
  /* ]]> */
  </style>
</head>
<body>
<h1>Prototype Unit test file</h1>
<p>
  Test of extra methods mixed in to elements with $() and $$().
</p>

<!-- Log output -->
<div id="testlog"> </div>

<h2>Test Form Elements</h2>
<form id="form">
  <input type="text" id="input" value="4" />
  <input type="submit" />
</form>

<!-- Tests follow -->
<script type="text/javascript" language="javascript" charset="utf-8">
// <![CDATA[
Form.Element.Methods.coffee = Prototype.K;
Element.addMethods();

  new Test.Unit.Runner({
    testInput: function() {with(this) {
      assert($("input").present != null);
      assert(typeof $("input").present == 'function');
      assert($("input").select != null);
      assertRespondsTo('present', Form.Element);
      assertRespondsTo('present', Form.Element.Methods);
      assertRespondsTo('coffee', $('input'));
      assertIdentical(Prototype.K, Form.Element.coffee);
      assertIdentical(Prototype.K, Form.Element.Methods.coffee);
    }},
    
    testForm: function() {with(this) {
      assert($("form").reset != null);
      assert($("form").getInputs().length == 2);
    }},
    
    testEvent: function() {with(this) {
      assert($("form").observe != null)
      // Can't really test this one with TestUnit...
      $('form').observe("submit", function(e) { 
        alert("yeah!"); 
        Event.stop(e); 
      });
    }},
    
    testCollections: function() {with(this) {
      assert($$("input").all(function(input) {
        return (input.focus != null);
      }));
    }}
  }, 'testlog');
// ]]>
</script>
</body>
</html>